﻿//$(function () {

//    app.mainNav.Model = function () {
//        var self = this;

//        self.item = ko.observable();

//        self.IsHome = ko.computed(function () {
//            return self.item == 'Home' ? "navSelected" : "";
//        });

//        self.IsAbout = ko.computed(function () {
//            return self.item == 'About' ? "navSelected" : "";
//        });

//        self.NavItemClicked = function (page) {
//            self.item(page);
//        };
//    };

//    app.mainNav.viewmodel = (function () {
//        var item = new app.mainNav.Model()
//            .item("Home");

//        return { item: item };

//    })();

//    ko.applyBindings(app.mainNav.viewmodel);
//});


app.mainNav = app.mainNav || {};

//app.mainNav.Model = function () {
//    var self = this;
//    
//    self.page = ko.observable('Home');

//    self.IsHome = ko.computed(function() {
//        var result = self.page() == 'Home' ? "navSelected" : "";
//        return result;
//    });

//    self.IsAbout = ko.computed(function () {
//        var result = self.page() == 'About' ? "navSelected" : "";
//        return result;
//    });
//};

//app.mainNav.init = function () {
//    ko.applyBindings(new app.mainNav.Model());
//};



$(function () {
    //Constructor for a Person object
    app.mainNav.Page = function () {
        var self = this;

        self.Name = ko.observable();
    };

    app.mainNav.model = (function () {
        //private
        var page = new app.mainNav.Page()
            .Name = 'Home';

        var isHome = ko.computed(function () {
            var result = page == 'Home' ? "navSelected" : "";
            return result;
        });

        var isAbout = ko.computed(function () {
            var result = page == 'About' ? "navSelected" : "";
            return result;
        });

        var setPage = function (data, event) {
            page.Name = 'About';
        };

        return {
            page: page,
            isHome: isHome,
            isAbout: isAbout,
            setPage: setPage
        };

    })();
    //hookup knockout to our viewmodel
    ko.applyBindings(app.mainNav.model);
});